    {% if not name_prefix %}
      {% set name_prefix = "" %}
    {% endif %}

    {% if each_option['type'] == 'message' %}

<div class="col-12" style="padding-top: 1em; padding-bottom: 0.5em">
  {{each_option['default_value']|safe}}
</div>

    {% elif each_option['type'] == 'new_line' %}

</div>
<div class="row small-gutters align-items-end" style="padding: 0.5em">

    {% elif each_option['type'] in ['float', 'integer', 'text'] %}

<div class="{% if 'col_width' in each_option %}col-{{each_option['col_width']}}{% else %}col-auto{% endif %}">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <input class="form-control" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}" type="
    {%- if each_option['type'] == 'text' -%}text
    {%- elif each_option['type'] in ['float', 'integer'] -%}number
    {%- endif -%}
    "
    {%- if each_option['type'] == 'float' %} step="any" {% else %} {% endif -%}
    value="
    {%- if channel_options and custom_options_values[unique_id][channel][each_option['id']] is not none -%}
      {{custom_options_values[unique_id][channel][each_option['id']]}}
    {%- elif custom_options_values and custom_options_values[unique_id][each_option['id']] is not none -%}
      {{custom_options_values[unique_id][each_option['id']]}}
    {%- elif force_default_value and 'default_value' in each_option -%}
      {{each_option['default_value']}}
    {%- endif -%}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{%- endif -%}
    >
  </div>
</div>

    {% elif each_option['type'] == 'multiline_text' %}

<div class="col-12">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <textarea style="font-family:monospace;" class="form-control" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" rows="{{each_option['lines']}}" type="text" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
    {%- if channel_options and custom_options_values[unique_id][channel][each_option['id']] is not none -%}
      {{custom_options_values[unique_id][channel][each_option['id']]}}
    {%- elif custom_options_values and custom_options_values[unique_id][each_option['id']] -%}
      {{custom_options_values[unique_id][each_option['id']]}}
    {%- elif force_default_value and 'default_value' in each_option -%}
      {{each_option['default_value']}}
    {%- endif -%}
    </textarea>
  </div>
</div>

    {% elif each_option['type'] == 'bool' %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div class="input-group-text">
    <input id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}" type="checkbox" value="y"
      {%- if (channel_options and custom_options_values[unique_id][channel][each_option['id']]) or
             (custom_options_values and custom_options_values[unique_id][each_option['id']]) or
             (force_default_value and 'default_value' in each_option and each_option['default_value'])%} checked{% endif %}
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
  </div>
</div>

    {% elif each_option['type'] == 'select' %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}">
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% for each_set in each_option['options_select'] %}
      <option value="{{each_set[0]}}"
        {%- if (channel_options and each_set[0] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_set[0] == custom_options_values[unique_id][each_option['id']]) -%}
          {{' selected'}}
        {%- elif custom_options_values and
               (each_set[0] == custom_options_values[unique_id][each_option['id']] or
                (force_default_value and
                'default_value' in each_option and
                each_set[0] == each_option['default_value'])) %}
          {{' selected'}}
        {%- endif -%}
      >{{each_set[1]}}</option>
      {% endfor %}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'select_custom_choices' %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% if each_option['id'] + '_choices' in custom_options_values[unique_id] %}
        {% set choices = custom_options_values[unique_id][each_option['id'] + '_choices'] %}
      {% elif each_option['id'] + '_choices' in custom_options_values[unique_id][channel] %}
        {% set choices = custom_options_values[unique_id][channel][each_option['id'] + '_choices'] %}
      {% else %}
        {% set choices = [] %}
      {% endif %}
    ASDF {{ choices }} QWER
      {% if choices %}
        {% for each_set in choices %}
      <option value="{{each_set[0]}}"
          {%- if (channel_options and each_set[0] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_set[0] == custom_options_values[unique_id][each_option['id']]) -%}
            {{' selected'}}
          {%- elif custom_options_values and
                   (each_set[0] == custom_options_values[unique_id][each_option['id']] or
                    (force_default_value and
                    'default_value' in each_option and
                    each_set[0] == each_option['default_value'])) %}
            {{' selected'}}
          {%- endif -%}
      >{{each_set[1]}}</option>
        {% endfor %}
      {% endif %}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'select_measurement' %}

      {% set form_choices = [
        ("Input", choices_input),
        ("Function", choices_function),
        ("Output", choices_output),
        ("Output_Channels_Measurements", choices_output_channels_measurements),
        ("Output_PWM", choices_output_pwm),
        ("PID", choices_pid)
      ] %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% for name, choices in form_choices %}
        {% if name in each_option['options_select'] %}
          {% for each_choice in choices -%}
      <option value="{{each_choice['value']}}"{% if (channel_options and each_choice['value'] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_choice['value'] == custom_options_values[unique_id][each_option['id']]) -%} selected{% endif %}>{{each_choice['item']}}</option>
          {% endfor -%}
        {% endif %}
      {% endfor %}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'select_measurement_from_this_input' %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% for each_choice in choices_input if each_choice['value'].startswith(each_input.unique_id) -%}
      <option value="{{each_choice['value']}}"{% if (channel_options and each_choice['value'] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_choice['value'] == custom_options_values[unique_id][each_option['id']]) -%} selected{% endif %}>{{each_choice['item']}}</option>
      {% endfor -%}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'select_channel' %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% if 'Output_Channels' in each_option['options_select'] %}
        {% for each_output_form in choices_output_channels -%}
      <option value="{{each_output_form['value']}}"{% if (channel_options and each_output_form['value'] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_output_form['value'] == custom_options_values[unique_id][each_option['id']]) %} selected{% endif %}>{{each_output_form['item']}}</option>
        {% endfor -%}
      {% endif %}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'select_measurement_channel' %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% if 'Output_Channels_Measurements' in each_option['options_select'] %}
        {% for each_output_form in choices_output_channels_measurements -%}
      <option value="{{each_output_form['value']}}"{% if (channel_options and each_output_form['value'] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_output_form['value'] == custom_options_values[unique_id][each_option['id']]) %} selected{% endif %}>{{each_output_form['item']}}</option>
        {% endfor -%}
      {% endif %}
      {% if 'Output_PWM_Channels_Measurements' in each_option['options_select'] %}
        {%- for each_output_form in choices_output_channels_measurements if 'pwm' in each_output_form['types'] -%}
      <option value="{{each_output_form['value']}}"{% if (channel_options and each_output_form['value'] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_output_form['value'] == custom_options_values[unique_id][each_option['id']]) %} selected{% endif %}>{{each_output_form['item']}}</option>
        {%- endfor -%}
      {% endif %}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'select_multi_measurement' %}

      {% set multiselect_size = 0 %}
      {% if 'Input' in each_option['options_select'] %}
        {% set multiselect_size = multiselect_size + choices_input|length %}
      {% endif %}
      {% if 'Function' in each_option['options_select'] %}
        {% set multiselect_size = multiselect_size + choices_function|length %}
      {% endif %}
      {% if 'Output' in each_option['options_select'] %}
        {% set multiselect_size = multiselect_size + choices_output|length %}
      {% endif %}
      {% if 'PID' in each_option['options_select'] %}
        {% set multiselect_size = multiselect_size + choices_pid|length %}
      {% endif %}
      {% if 'Tag' in each_option['options_select'] %}
        {% set multiselect_size = multiselect_size + choices_tag|length %}
      {% endif %}

      {% set form_choices = [
        ("Input", choices_input),
        ("Function", choices_function),
        ("Output", choices_output),
        ("PID", choices_pid),
        ("Tag", choices_tag)
      ] %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}" size="{{multiselect_size}}" multiple=""
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      {% for name, choices in form_choices %}
        {% if name in each_option['options_select'] %}
          {% for each_choice in choices -%}
      <option value="{{each_choice['value']}}"{% if (channel_options and each_choice['value'] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_choice['value'] in custom_options_values[unique_id][each_option['id']]) %} selected{% endif %}>{{each_choice['item']}}</option>
          {% endfor -%}
        {% endif %}
      {% endfor %}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'select_device' %}

      {% set form_choices = [
        ("Input", table_input.query.all()),
        ("Output", table_output.query.all()),
        ("PID", table_pid.query.all()),
        ("Trigger", table_trigger.query.all()),
        ("Camera", table_camera.query.all()),
        ("Function", table_function.query.all()),
        ("Conditional", table_conditional.query.all())
      ] %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% for name, devices in form_choices %}
        {% if name in each_option['options_select'] %}
          {%- for each_dev in devices -%}
      <option value="{{each_dev.unique_id}}"{% if (channel_options and each_dev.unique_id == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_dev.unique_id == custom_options_values[unique_id][each_option['id']]) %} selected{% endif %}>[{{name}} {{'%02d' % each_dev.id}}] {{each_dev.name}}</option>
          {%- endfor -%}
        {% endif %}
      {% endfor %}

      {% if 'Method' in each_option['options_select'] %}
        {% for each_method_form in choices_method -%}
      <option value="{{each_method_form['value']}}"{% if (channel_options and each_method_form['value'] == custom_options_values[unique_id][channel][each_option['id']]) or (custom_options_values and each_method_form['value'] == custom_options_values[unique_id][each_option['id']]) %} selected{% endif %}>{{each_method_form['item']}}</option>
        {% endfor -%}
      {% endif %}
    </select>
  </div>
</div>

      {% elif each_option['type'] == 'select_type_measurement' %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% for each_measure_name_safe, each_measure in dict_measurements.items() %}
      <option value="{{each_measure_name_safe}}"
        {%- if (channel_options and each_measure_name_safe == custom_options_values[unique_id][channel][each_option['id']]) or
               (custom_options_values and each_measure_name_safe == custom_options_values[unique_id][each_option['id']]) or
               (force_default_value and 'default_value' in each_option and each_measure_name_safe == each_option['default_value']) %}
          {{' selected'}}
        {%- endif -%}
      >{{each_measure_name_safe}}</option>
      {% endfor %}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'select_type_unit' %}

<div class="col-auto">
  <label class="control-label" for="{{name_prefix}}{{each_option['id']}}">{{each_option['name']}}</label>
  <div>
    <select class="form-control form-tooltip form-dropdown" data-placement="top" id="{{name_prefix}}{{each_option['id']}}" name="{{name_prefix}}{{each_option['id']}}" title="{{each_option['phrase']}}"
    {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
    >
      <option value="">{{dict_translation['select_one']['title']}}</option>
      {% for each_unit_name_safe, each_unit in dict_units.items() %}
      <option value="{{each_unit_name_safe}}"
        {%- if (channel_options and each_unit_name_safe == custom_options_values[unique_id][channel][each_option['id']]) or
               (custom_options_values and each_unit_name_safe == custom_options_values[unique_id][each_option['id']]) or
               (force_default_value and 'default_value' in each_option and each_unit_name_safe == each_option['default_value']) %}
          {{' selected'}}
        {%- endif -%}
      >{{each_unit_name_safe}}</option>
      {% endfor %}
    </select>
  </div>
</div>

    {% elif each_option['type'] == 'button' %}

  <div class="col-auto small-gutters">
      <input onclick="return $(this).processRequest(this, 'custom_button_{{each_option['id']}}');" name="custom_button_{{each_option['id']}}" title="{{each_option['phrase']}}" class="form-control btn btn-primary btn-sm btn-block" type="button" value="{{each_option['name']}}"
      {%- if 'disabled' in each_option and each_option['disabled'] %} disabled{% endif -%}
      />
  </div>

    {% endif %}
